package cn.iocoder.yudao.module.crossborder.order.dal.mysql.orderaddress;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.crossborder.order.dal.dataobject.orderaddress.OrderAddressDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.crossborder.order.controller.admin.orderaddress.vo.*;

/**
 * 跨境电商订单地址 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface OrderAddressMapper extends BaseMapperX<OrderAddressDO> {

    default PageResult<OrderAddressDO> selectPage(OrderAddressPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OrderAddressDO>()
                .eqIfPresent(OrderAddressDO::getOrderId, reqVO.getOrderId())
                .eqIfPresent(OrderAddressDO::getAddressType, reqVO.getAddressType())
                .likeIfPresent(OrderAddressDO::getFirstName, reqVO.getFirstName())
                .likeIfPresent(OrderAddressDO::getLastName, reqVO.getLastName())
                .likeIfPresent(OrderAddressDO::getFullName, reqVO.getFullName())
                .eqIfPresent(OrderAddressDO::getCompany, reqVO.getCompany())
                .eqIfPresent(OrderAddressDO::getPhone, reqVO.getPhone())
                .eqIfPresent(OrderAddressDO::getEmail, reqVO.getEmail())
                .eqIfPresent(OrderAddressDO::getCountryCode, reqVO.getCountryCode())
                .likeIfPresent(OrderAddressDO::getCountryName, reqVO.getCountryName())
                .eqIfPresent(OrderAddressDO::getProvince, reqVO.getProvince())
                .eqIfPresent(OrderAddressDO::getCity, reqVO.getCity())
                .eqIfPresent(OrderAddressDO::getDistrict, reqVO.getDistrict())
                .eqIfPresent(OrderAddressDO::getAddressLine1, reqVO.getAddressLine1())
                .eqIfPresent(OrderAddressDO::getAddressLine2, reqVO.getAddressLine2())
                .eqIfPresent(OrderAddressDO::getPostalCode, reqVO.getPostalCode())
                .eqIfPresent(OrderAddressDO::getLatitude, reqVO.getLatitude())
                .eqIfPresent(OrderAddressDO::getLongitude, reqVO.getLongitude())
                .eqIfPresent(OrderAddressDO::getTaxId, reqVO.getTaxId())
                .eqIfPresent(OrderAddressDO::getCustomsInfo, reqVO.getCustomsInfo())
                .betweenIfPresent(OrderAddressDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(OrderAddressDO::getId));
    }

}